package TransactionImplementation

import (
	"SalaryPayment/AbstractTransactions"
	"SalaryPayment/DataBase"
	"SalaryPayment/Model"
	"SalaryPayment/ModelImplementation"
	"reflect"
)

type ChangeUnaffiliatedTransaction struct {
	AbstractTransactions.ChangeAffiliationTransaction
}

func (cut *ChangeUnaffiliatedTransaction) RecordMembership(e Model.Employee) {
	af := e.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		memberId := uaf.GetMemberId()
		DataBase.PayrollDatabase.Default.RemoveUnionMember(memberId)
	}
}

func (cut *ChangeUnaffiliatedTransaction) GetAffiliation() Model.Affiliation {
	return Model.NoAffiliation{}
}